import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 回收时间贬值信息 */
export interface TimeDevaluat {
  devaluatProportion?: number // 贬值比例
  devaluatName: string // 贬值名称
  time: number // 时长(单位天)
  status: number // 状态(0-禁用,1-启用)
  sort: number // 排序值
  remarks: string // 备注
  children?: TimeDevaluat[]
}

// 回收时间贬值 API
export const TimeDevaluatApi = {
  // 查询回收时间贬值列表
  getTimeDevaluatList: async (params) => {
    return await request.get({ url: `/recycle/time-devaluat/list`, params })
  },

  // 查询回收时间贬值详情
  getTimeDevaluat: async (id: number) => {
    return await request.get({ url: `/recycle/time-devaluat/get?id=` + id })
  },

  // 新增回收时间贬值
  createTimeDevaluat: async (data: TimeDevaluat) => {
    return await request.post({ url: `/recycle/time-devaluat/create`, data })
  },

  // 修改回收时间贬值
  updateTimeDevaluat: async (data: TimeDevaluat) => {
    return await request.put({ url: `/recycle/time-devaluat/update`, data })
  },

  // 删除回收时间贬值
  deleteTimeDevaluat: async (id: number) => {
    return await request.delete({ url: `/recycle/time-devaluat/delete?id=` + id })
  },

  // 导出回收时间贬值 Excel
  exportTimeDevaluat: async (params) => {
    return await request.download({ url: `/recycle/time-devaluat/export-excel`, params })
  }
}
